Export renderer#4
Conversation
PR SummaryMedium Risk Overview
Written by Cursor Bugbot for commit b7ccf05. This will update automatically on new commits. Configure here. |
| editor, | ||
| ]) | ||
| const { ShapeRenderer } = useEditorComponents() | ||
| const Renderer = ShapeRenderer ?? DefaultShapeRenderer |
There was a problem hiding this comment.
Null ShapeRenderer silently falls back instead of disabling
Medium Severity
The ShapeRenderer type includes | null, following the convention of other editor components where null means "disable this component." However, the consumption site uses ShapeRenderer ?? DefaultShapeRenderer, which silently falls back to the default when null is provided. Every other nullable component in the codebase uses if (!Component) return null or {Component && ...} to respect the null-means-disabled contract. This breaks the established API contract — a user passing ShapeRenderer: null would expect shape rendering to be disabled but would instead get the default renderer.
Additional Locations (1)
|
Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.
Or push these changes by commenting: Preview (18ea1d25c4)diff --git a/packages/editor/src/lib/components/default-components/DefaultCanvas.tsx b/packages/editor/src/lib/components/default-components/DefaultCanvas.tsx
--- a/packages/editor/src/lib/components/default-components/DefaultCanvas.tsx
+++ b/packages/editor/src/lib/components/default-components/DefaultCanvas.tsx
@@ -4,6 +4,7 @@
import { dedupe, modulate, objectMapValues } from '@tldraw/utils'
import classNames from 'classnames'
import { Fragment, JSX, ReactElement, useEffect, useRef, useState } from 'react'
+import type { TLRenderingShape } from '../../editor/Editor'
import { tlenv } from '../../globals/environment'
import { useCanvasEvents } from '../../hooks/useCanvasEvents'
import { useCoarsePointer } from '../../hooks/useCoarsePointer'
@@ -26,7 +27,6 @@
import { LiveCollaborators } from '../LiveCollaborators'
import { MenuClickCapture } from '../MenuClickCapture'
import { Shape } from '../Shape'
-import type { TLRenderingShape } from '../../editor/Editor'
/** @public */
export interface TLCanvasComponentProps {
@@ -435,11 +435,12 @@
function ShapesToDisplay() {
const { ShapeRenderer } = useEditorComponents()
- const Renderer = ShapeRenderer ?? DefaultShapeRenderer
+ if (!ShapeRenderer) return tlenv.isSafari ? <ReflowIfNeeded /> : null
+
return (
<>
- <Renderer renderShape={(shape) => <Shape key={shape.id + '_shape'} {...shape} />} />
+ <ShapeRenderer renderShape={(shape) => <Shape key={shape.id + '_shape'} {...shape} />} />
{tlenv.isSafari && <ReflowIfNeeded />}
</>
) |



Export
ShapeRendereras a customizable component.